#ifndef MAINTASK_H
#define MAINTASK_H

#include <QObject>
#include <QDir>
#include <QDebug>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QTimer>

#include "../networkserver.h"
#include "../powermeter.h"
#include "../extcontrol.h"
#include "../i2c.h"
#include "../../common.h"

#define STARTUP_DELAY 500

class MainTask : public QObject
{
  Q_OBJECT
public:
  explicit MainTask(QObject *parent = 0);
  ~MainTask();
  void loadSettings(QSettings &settings);
  QTimer *powerMeterTimer;
signals:

public slots:
  void networkDataReady(QByteArray data);
  void powerMeterSendData();
  void networkError(const int &errorCode, const QString &errorString);
  void networkClientConnected();
  void networkClientDisconnected();
  void init();
private:
  NetworkServer *tcpServer;
  PowerMeter *powerMeter;
  ExtControl *extControl;
  I2C *i2c2;
  QTimer *blinkTimer;
};

#endif // MAINTASK_H
